package com.tvunetworks.center.user.controller;

import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.common.util.ResultUtil;
import com.tvunetworks.center.user.model.vo.UserIdWithEmail;
import com.tvunetworks.center.user.service.UserSFAccountRelationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: tvucc-aggregator
 * @description: SalesforceUserController
 * @author lebronchen
 * @create: 2019-06-17 15:53
 **/
@RestController
@RequestMapping("/salesforce")
@Slf4j
public class UserSFAccountRelationController {

    @Autowired
    private UserSFAccountRelationService userSFAccountRelationService;


    /**
     * 和SFAccount没有绑定关系的User
     * @param account account
     * @param email email
     * @return Result
     */
    @GetMapping("/listUnbindSFAccountUser")
    public Result<Object> listUnbindSFAccountUser(@RequestParam String account, String email){
        List<UserIdWithEmail> list = userSFAccountRelationService.listUnbindSFAccountUser(account, email);
        return ResultUtil.success(list);
    }

    /**
     * 和SFAccount有绑定关系的User
     * @param account account
     * @param email email
     * @return Result
     */
    @GetMapping("/listBindedSFAccountUser")
    public Result<Object> listBindedSFAccountUser(@RequestParam String account, String email){
        List<UserIdWithEmail> list = userSFAccountRelationService.listBindedSFAccountUser(account, email);
        return ResultUtil.success(list);
    }

    /**
     * 添加移除SFAccount和User的绑定关系
     * @param account account
     * @param addUserIds addUserIds
     * @param removeUserIds removeUserIds
     * @return Result
     */
    @PostMapping("/correlateSFAccountUserRelation")
    public Result<Object> correlateSFAccountUserRelation(@RequestParam String account, @RequestParam String addUserIds, @RequestParam  String removeUserIds){
        userSFAccountRelationService.correlateSFAccountUserRelation(account, addUserIds, removeUserIds);
        return ResultUtil.success();
    }
}
